home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / c / ExtrasLib.lha / ExtrasLib / Include / Extras / threads.h < prev   
Encoding:
C/C++ Source or Header  |  2000-09-30  |  2.0 KB  |  90 lines

  1. #ifndef EXTRAS_THREADS_H
  2. #define EXTRAS_THREADS_H
  3.  
  4. #ifndef EXEC_NODES_H
  5. #include "exec/nodes.h"
  6. #endif /* EXEC_NODES_H */
  7.  
  8. #ifndef EXEC_LISTS_H
  9. #include "exec/lists.h"
  10. #endif /* EXEC_LISTS_H */
  11.  
  12. #ifndef EXEC_TASKS_H
  13. #include "exec/tasks.h"
  14. #endif /* EXEC_TASKS_H */
  15.  
  16. #ifndef EXEC_PORTS_H
  17. #include <exec/ports.h>
  18. #endif
  19.  
  20. #ifndef UTILITY_TAGITEM_H
  21. #include <utility/tagitem.h>
  22. #endif
  23.  
  24. /* TAGS */
  25. #define TA_DUMMY(x)    (TAG_USER + (x))
  26.                                    // Defaults
  27. #define TA_Name       TA_DUMMY(1) // "Thread"
  28. #define TA_Stack      TA_DUMMY(2) // 8192
  29. #define TA_Priority   TA_DUMMY(3) // -1
  30.  
  31. //#define TA_Entry      TA_DUMMY(4) // Entry
  32. #define TA_MsgHandler TA_DUMMY(5) // Required
  33.  
  34. #define TA_UserData   TA_DUMMY(6) // (APTR)
  35.  
  36. /* Proto for thread entry
  37.  
  38. ULONG __asm __saveds ThreadMsgHandler( register __a0 struct Thread *T,
  39.                                        register __a1 struct ThreadMessage *TMsg)
  40.  
  41. */
  42.  
  43. /* Readable ONLY unless otherwise marked */
  44. struct Thread
  45. {
  46.   struct Node t_Node; // Application use
  47.   STRPTR TName; 
  48.   struct Process *t_Process;
  49.   struct MsgPort *t_MsgPort;
  50.   struct ThreadMessage *t_CurrentMsg;
  51.   APTR   UserData;    // Application use
  52.   APTR   ThreadData;  // App/Thread use
  53. };
  54.  
  55. // ThreadMessage.tm_Command
  56.  
  57. /* USER messages MUST NOT HAVE 1<<31 set */
  58.  
  59. #define TMSG_DUMMY(x)     ((1<<31) + (x))
  60. #define TMSG_INTERNAL_BIT TMSG_DUMMY(0)  // User messages must not have this bit set.
  61. #define TMSG_DIE          TMSG_DUMMY(1)  // All threads shoul respect this message.
  62. #define TMSG_SIGNAL       TMSG_DUMMY(2)  // Thread has been Signaled.
  63. #define TMSG_SIGNALED     TMSG_DUMMY(2)  // Thread has been Signaled.
  64.  
  65. /* Basic thread message */
  66. struct ThreadMessage
  67. {
  68.   struct Message  tm_Msg;
  69.   ULONG           tm_Command;
  70.   // User data follows
  71. };
  72.  
  73. struct TMsg_TagList
  74. {
  75.   struct Message  tm_Msg;
  76.   ULONG           tm_Command,
  77.                   tm_RetVal;
  78.   struct TagItem  *tm_TagList;
  79. };
  80.  
  81. struct TMsg_Signal
  82. {
  83.   struct ThreadMessage TMsg;
  84.   ULONG  Signal;
  85. };
  86.  
  87.  
  88.  
  89. #endif /* EXTRAS_THREADS_H */
  90.